home *** CD-ROM | disk | FTP | other *** search
- /* memchr.c, from p.149 of Turbo C Bible */
- /* Searches for a specific character in
- a given number of bytes of the buffer */
- /* Use the large memory model (-ml flag) */
- #include <stdio.h>
- #include <dos.h>
- #include <mem.h>
- /* Copyright notice begins at segment F000 and offset E000 */
- #define COPYRIGHT_NOTICE MK_FP(0Xf000,0Xe000)
- static char dest[81]; /* Destination buffer */
- main()
- {
- void *copr_address, *first_i;
- copr_address = COPYRIGHT_NOTICE;
- if((first_i = memchr(copr_address, 'I', 24)) == NULL)
- /* Look for the 'I' */
- { /* of IBM in the copyright notice */
- printf("Search failed!\n");
- }
- else
- {
- printf("Found an 'I' at %p\n", first_i);
- memcpy(dest, first_i, 8);/* Copy next 8 characters into */
- dest[8] = '\0'; /* buffer 'dest' for printing */
- printf("The next 8 characters are: %s\n", dest);
- }
- }